import { UserInfo } from '@renderer/api'
import { defineStore } from 'pinia'
import { computed, reactive, ref } from 'vue'

export const useOperationConfiguration = defineStore('viewConfig', () => {
  const shortcutKey = reactive({
    translate: 'w',
    rotate: 'e',
    scale: 'r',
    // measure: 'm',
    repeal: 'z',
    recover: 'y',
    focus: 'f',
    delete: 'Delete',
    save: 's'
  })

  const userInfo = ref<UserInfo>()

  function setUserInfo(data) {
    userInfo.value = data
  }

  function setToken(str: string) {
    if (userInfo.value) {
      userInfo.value.token = str
    }
  }

  const token = computed(() => {
    return userInfo.value?.token
  })

  const customerNo = computed(() => {
    return userInfo.value?.customerNo
  })

  return { shortcutKey, userInfo, customerNo, token, setToken, setUserInfo }
})
